﻿@model ITS.Core.ViewModel.Contents.EditContentItemViewModel
@{
    ViewBag.Title = "EditContentItem";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section cssholder {
    <link href="/Scripts/jquery-ui/jquery-ui-1.8.23.custom/css/flick/jquery-ui-1.8.23.custom.css"
        rel="stylesheet" type="text/css" />
}
<h2>
    EditContentItem</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Edit your content</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.SubCategoryID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.SubCategoryID, Model.SubCategories)
            @Html.ValidationMessageFor(model => model.SubCategoryID)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Active)
            @Html.ValidationMessageFor(model => model.Active)
            <span>@Html.LabelFor(model => model.Active)</span>
        </div>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}
<div>
    <table width="100%">
        <tr>
            <th>
                Language
            </th>
            <th>
                Title
            </th>
            <th>
                Description
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model.ContentItemDescriptions)
        {
            <tr>
                <td>@item.LanguageID
                </td>
                <td>@item.Title
                </td>
                <td>@item.Description
                </td>
                <td>
                    <span><a title="@item.DescriptionID" class="editDescriptionLink">Edit</a></span>
                </td>
            </tr>
        }
    </table>
    <p>
    <input type="button" id="bntAddContentItemDescription" value="Add more translation" />
    </p>
</div>
<div>
    @Html.ActionLink("Back to Adnin page", "Index", "Admin", null,null)
</div>
<div id="mainPopup" style="display: none">
    <div class="centerContent">
        <img src="../../Themes/vnGreeks/images/ajax-spinner-med.gif" /></div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery-latest.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery-ui/jquery-ui-1.8.23.custom/js/jquery-ui-1.8.23.custom.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script type="text/javascript">
    var $dialog = $("#mainPopup").dialog({ position: 'center', autoOpen: false, title: 'Translation', disabled: true, modal: true, height: '600', width: '850', show: 'slide', hide: 'slide'
    });
    $(".editDescriptionLink").click(function () {
        document.getElementById("mainPopup").innerHTML = "<div class='centerContent'><img src='../../Themes/vnGreeks/images/ajax-spinner-med.gif'/></div>";
        var desc = $(this).attr("title");
        $dialog.dialog('open');
        $.post('@Url.Action("EditContentDescription", "Content")', { 'descriptionID': desc },
            function (data) {
                document.getElementById("mainPopup").innerHTML = data;
                jQuery.validator.unobtrusive.parse("#EditContentItemDescriptionForm");
            });
        });
        $("#bntAddContentItemDescription").click(function () {
            document.getElementById("mainPopup").innerHTML = "<div class='centerContent'><img src='../../Themes/vnGreeks/images/ajax-spinner-med.gif'/></div>";
            var content = '@Model.ContentID'
            $dialog.dialog('open');
            $.post('@Url.Action("AddContentDescription", "Content")', { 'contentID': content },
            function (data) {
                document.getElementById("mainPopup").innerHTML = data;
                jQuery.validator.unobtrusive.parse("#AddContentItemDescriptionForm");
            });
        });
</script>
